|
www.mxdraw.com
|
向块引用中增一个属性定义对象
[helpstring("method AppendAttribute")]
HRESULT AppendAttribute([out,retval] IMxDrawAttribute** ppNewAttribute);|
参数 |
说明 |
|
[out,retval] IMxDrawAttribute** ppNewAttribute |
返回新的属性定义对象 |
例如: 向块中增加一个属性文字 C#代码
MxDrawAttribute attrib = blkRef.AppendAttribute();
attrib.Position = pos;
attrib.AlignmentPoint = pos;
attrib.Oblique = 0.0;
attrib.Rotation = 0.0;
attrib.Height = 2.0;
attrib.TrueColor.SetRGB(255,0,0);
attrib.TextString = "这是一个属性文字的测试";
attrib.Tag = "TestTag";
attrib.IsInvisible = false;
blkRef.Position = blkRef.Position;例如: Delphi中的例程
procedure TForm1.DoInsertFlagClick();
var
ptInsert : OleVariant;
pt : IMxDrawPoint ;
lId : Integer;
curDababase : IMxDrawDatabase;
pObj : IMxDrawMcDbObject;
pBlkRef : IMxDrawBlockReference;
pAtrribText : IMxDrawAttribute;
begin
ptInsert := mxUtility.GetPoint(EmptyParam,'点插入点');
pt:=IMxDrawPoint(IDisPatch(ptInsert));
if pt = nil then
EXIT;
MxDrawX1.InsertBlock(MxDrawX1.GetOcxAppPath() + 'blkTsgNote.dwg','Flag');
lId := MxDrawX1.DrawBlockReference(pt.Get_x(),pt.Get_y(),'Flag',10.0,0.0);
curDababase := IMxDrawDatabase(MxDrawX1.GetDatabase() );
if curDababase = nil then
EXIT;
pObj := curDababase.ObjectIdToObject(lId);
pObj.QueryInterface(IMxDrawBlockReference, pBlkRef);
if pBlkRef <> nil then
begin
pBlkRef.Set_Position(pBlkRef.Position);
pAtrribText := pBlkRef.AppendAttribute();
if pAtrribText <> nil then
begin
pAtrribText.Set_Oblique(0.0);
pAtrribText.Set_Position(pt);
pAtrribText.Set_AlignmentPoint(pt);
pAtrribText.Set_Rotation(0.0);
pAtrribText.Set_Height(2.0);
//pAtrribText.TrueColor.SetRGB(255,0,0);
pAtrribText.Set_TextString('这是一个属性文字的测试');
pAtrribText.Set_Tag('TestTag');
pAtrribText.Set_IsInvisible(false);
pBlkRef.Set_Position(pBlkRef.Position);
end;
end;
end;